<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/8/12
 * Time: 4:32 PM
 * To change this template use File | Settings | File Templates.
 */
defined('_JEXEC') or die;

class VastViewTailieu extends JViewLegacy
{
    protected $form;
    protected $item;
    protected $state;
    protected $canDo;
    
    /**
     * Display the view
     */
    public function display($tpl = null)
    {
        // Initialiase variables.
        $this->form		= $this->get('Form');
        $this->item		= $this->get('Item');
        $this->state	= $this->get('State');

        JLoader::register('TailieusHelper', JPATH_COMPONENT . '/helpers/tailieu.php');

        $this->canDo	= TailieusHelper::getActions();

        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }

        $this->addToolbar();
        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar.
     *
     * @since	1.6
     */
    protected function addToolbar()
    {
        JRequest::setVar('hidemainmenu', true);
        $isNew		= ($this->item->id == 0);
        JToolBarHelper::title(JText::_('COM_VAST_TAILIEU_DETAIL'), 'head vm_manufacturer_48');

        JToolBarHelper::divider();

        if ($this->canDo->get('vast.tailieu.edit')) {
            JToolBarHelper::save2new('tailieu.save2new', 'COM_VAST_JTOOLBAR_SAVE2NEW');
            JToolBarHelper::save2copy('tailieu.save2copy', 'COM_VAST_JTOOLBAR_SAVE2COPY');
            JToolBarHelper::save('tailieu.save', 'COM_VAST_JTOOLBAR_SAVE');            
        }
        JToolBarHelper::cancel('tailieu.cancel', $isNew ? 'COM_VAST_JTOOLBAR_CANCEL' : 'COM_VAST_JTOOLBAR_CLOSE');
    }
}